home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
TEX-UTIL
/
DVI_DVI1
/
dvilj
/
c
/
dvifont
< prev
next >
Wrap
Text File
|
1996-02-20
|
29KB
|
840 lines
#include "dvilj.h"
/*-->GetFontDef*/
/**********************************************************************/
/**************************** GetFontDef *****************************/
/**********************************************************************/
void
GetFontDef(void)
/***********************************************************************
Read the font definitions as they are in the postamble of the DVI
file.
***********************************************************************/
{
unsigned char byte;
while (((byte = (unsigned char) NoSignExtend(dvifp, 1)) >= FNT_DEF1) &&
(byte <= FNT_DEF4)) {
switch (byte) {
case FNT_DEF1:
ReadFontDef ( NoSignExtend(dvifp, 1));
break;
case FNT_DEF2:
ReadFontDef ( NoSignExtend(dvifp, 2));
break;
case FNT_DEF3:
ReadFontDef ( NoSignExtend(dvifp, 3));
break;
case FNT_DEF4:
ReadFontDef ( NoSignExtend(dvifp, 4));
break;
default:
Fatal ("Bad byte value in font defs");
break;
}
}
if (byte != POST_POST)
Fatal ("POST_POST missing after fontdefs");
}
/*-->OpenFontFile*/
/**********************************************************************/
/************************** OpenFontFile *****************************/
/**********************************************************************/
void
OpenFontFile(void)
/***********************************************************************
The original version of this dvi driver reopened the font file each
time the font changed, resulting in an enormous number of relatively
expensive file openings. This version keeps a cache of up to
MAXOPEN open files, so that when a font change is made, the file
pointer, pxlfp, can usually be updated from the cache. When the
file is not found in the cache, it must be opened. In this case,
the next empty slot in the cache is assigned, or if the cache is
full, the least used font file is closed and its slot reassigned for
the new file. Identification\ of the least used file is based on the
counts of the number of times each file has been "opened" by this
routine. On return, the file pointer is always repositioned to the
beginning of the file.
***********************************************************************/
#if MAXOPEN > 1
{
int i, least_used, current;
struct pixel_list tmp;
FILEPTR fid;
struct font_entry *fp;
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM,"open font file %p\n", fontptr->font_file_id);
#endif
/*
fprintf(ERR_STREAM,"? %lx == %lx\n", pfontptr,fontptr);
*/
if ((pfontptr == fontptr) && (pxlfp != NO_FILE))
return; /* we need not have been called */
if (fontptr->font_file_id == NO_FILE)
return; /* we need not have been called */
tmp = pixel_files[1];
current = 1;
while ((current <= nopen) && (tmp.pixel_file_id != fontptr->font_file_id))
{
++current;
tmp = pixel_files[current];
}
/* try to find file in open list */
if (current <= nopen) /* file already open */ {
if (pixel_files[current].pixel_file_id != NO_FILE )
{
pxlfp = pixel_files[current].pixel_file_id;
FSEEK(pxlfp, 0l,SEEK_SET);
}
/* reposition to start of file */
} else {
/* file not in open list */
if (nopen < MAXOPEN) /* just add it to list */
current = ++nopen;
else {
/* list full -- find least used file, */
/* close it, and reuse slot for new file */
least_used = 1;
for (i = 2; i <= MAXOPEN; ++i)
if ((pixel_files[least_used].use_count) > (pixel_files[i].use_count))
{least_used = i;}
if ((fid = pixel_files[least_used].pixel_file_id) != NO_FILE) {
/* mark file as being closed in the entry */
fp = hfontptr;
while ((fp != NULL) && (fp->font_file_id != fid)) {fp = fp->next;}
if (fp == NULL)
Fatal("Open file %x not found in font entry list.\n", fid);
else {
fp->font_file_id = FPNULL;
}
BCLOSE( fid );
}
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM,"\n__reuse slot %d\n", least_used);
#endif
current = least_used;
}
if ((pxlfp = BINOPEN(fontptr->name)) == FPNULL) {
Warning("PXL-file %s could not be opened", fontptr->name);
pxlfp = NO_FILE;
} else {
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM,"Opening File <%s> /%p/, Size(font_entry)=%d\n",
fontptr->name, pxlfp, sizeof(struct font_entry ));
#endif
}
pixel_files[current].pixel_file_id = pxlfp;
pixel_files[current].use_count = 0;
}
pfontptr = fontptr; /* make previous = current font */
fontptr->font_file_id = pxlfp; /* set file identifier */
(pixel_files[current].use_count)++; /* update reference count */
#ifndef USEPXL
gfin = pxlfp;
#endif
}
#else
{
FILEPTR f;
struct font_entry *fp;
if ((pfontptr == fontptr) && (pxlfp != NO_FILE))
return; /* we need not have been called */
if (fontptr->font_file_id == NO_FILE)
return; /* we need not have been called */
f = pfontptr->font_file_id;
if (f != FPNULL)
{
if (pxlfp != FPNULL)
{
fp = hfontptr;
while ((fp != NULL) && (fp->font_file_id != f)) {fp = fp->next;}
if (fp == NULL) {Fatal("Open file %x not found in font entry list.\n",f);}
else {fp->font_file_id = FPNULL;}
}
BCLOSE(f);
}
if ((pxlfp = BINOPEN(fontptr->name)) == FPNULL)
{Warning("PXL-file %s could not be opened", fontptr->name);
pxlfp = NO_FILE;}
pfontptr = fontptr;
fontptr->font_file_id = pxlfp;
}
#endif
/*-->PixRound*/
/**********************************************************************/
/***************************** PixRound *****************************/
/**********************************************************************/
long4
PixRound(long4 x, long4 conv) /* return rounded number of pixels */
/* x in DVI units, conv conversion factor */
{
return((x + conv) / conv);
}
#ifdef LJ_RESIDENT_FONTS
/*-->TryResident*/
/**********************************************************************/
/**************************** TryResident ***************************/
/**********************************************************************/
bool
TryResident(struct font_entry *fontptr)
{
tfm_info_type tfm_info;
/* To determine if a font is resident, check for a special family
value (header bytes 12..16 in the TFM file). This seems cleaner,
and certainly more convenient, than somehow reading an external
ljfonts.map file in which we'd have to specify information for all
the resident fonts. */
if (tfm_read_info (fontptr->n, &tfm_info)
&& tfm_info.family[0]
&& strcmp (tfm_info.family, "HPAUTOTFM") == 0) {
unsigned i;
double factor = fontptr->s / (double) 0x100000;
resident_count++;
fontptr->resident_p = _TRUE;
strcpy (fontptr->symbol_set, tfm_info.coding_scheme);
fontptr->resid = tfm_info.typeface_id;
fontptr->spacing = tfm_info.spacing;
fontptr->style = tfm_info.style;
fontptr->weight = tfm_info.weight;
if (fontptr->spacing == SPACING_FIXED) {
/* Have to select the point in pitch (characters per inch) instead
of point size, and thus have to figure out the pitch that
corresponds to the point size at which the font is used.
To do this, take the width of the interword space, and see how
many of those characters will fit in the at size. Then convert
to how many characters will fit in one inch. That's our pitch.
All the builtin LJ4 fonts that are monospaced are Intellifont,
which have 72.307 points per inch. Not that it really makes any
difference. We don't worry about this elsewhere, since all
point sizes are rounded to .25pt anyway, which is more than the
difference between the various definitions of `point'. */
double ds_in_points = fontptr->s / 65536.0;
double w_in_points = tfm_info.interword / (double) 0x100000;
if (ds_in_points == 0 || w_in_points == 0) {
/* Avoid division by zero if no interword space. */
Warning ("%s: Can't determine pitch for this monospaced font.\n",
fontptr->n);
fontptr->pitch = 10; /* Result will look awful, which is good. */
} else {
fontptr->pitch = 72.307 / (ds_in_points * w_in_points);
}
}
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "%6s: typeface=%u\tspacing=%u\tstyle=%u\tweight=%d\n",
fontptr->n, fontptr->resid, fontptr->spacing,
fontptr->style, fontptr->weight);
#endif
for (i = 0; i < NFNTCHARS; i++) {
struct char_entry *cptr = &(fontptr->ch[i]);
cptr->tfmw = (long4) (tfm_info.widths[i] * factor);
cptr->cw = ((fontptr->ch[i].tfmw) / (double) hconv) + .5;
cptr->width =
cptr->height =
cptr->xOffset =
cptr->yOffset =
cptr->yyOffset = 0;
}
return _TRUE;
} else {
fontptr->resident_p = _FALSE;
if (tfm_info.family[0]
&& strcmp (tfm_info.family, "UNSPECIFIED") == 0) {
Warning("font family for %s is UNSPECIFIED; need to run dvicopy?",
fontptr->n);
fontptr->font_file_id = NO_FILE;
return _TRUE;
} else {
return _FALSE;
}
}
}
#endif
/*-->ReadFontDef*/
/**********************************************************************/
/**************************** ReadFontDef ***************************/
/**********************************************************************/
void
ReadFontDef(long4 k)
{
long4 t;
unsigned short i;
struct font_entry *tfontptr; /* temporary font_entry pointer */
struct char_entry *tcharptr; /* temporary char_entry pointer */
static int plusid = 0;
bool font_found = _FALSE;
#ifdef LJ_RESIDENT_FONTS
bool resident_font_located = _FALSE;
#endif
#ifdef LJ
int depth, max_depth;
#endif
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM,"Mallocating %d Bytes)...\n", sizeof(struct font_entry ));
#endif
if ((tfontptr = NEW(struct font_entry )) == NULL)
Fatal("can't malloc space for font_entry");
allocated_storage += sizeof(struct font_entry );
tfontptr->next = hfontptr;
tfontptr->font_file_id = FPNULL;
fontptr = hfontptr = tfontptr;
tfontptr->ncdl = 0;
tfontptr->k = k;
tfontptr->c = NoSignExtend(dvifp, 4); /* checksum */
tfontptr->s = NoSignExtend(dvifp, 4); /* space size */
tfontptr->d = NoSignExtend(dvifp, 4); /* design size */
tfontptr->a = (int) NoSignExtend(dvifp, 1); /* length for font name */
tfontptr->l = (int) NoSignExtend(dvifp, 1); /* device length */
#ifdef LJ
tfontptr->max_width = tfontptr->max_height = tfontptr->max_yoff =
max_depth = 0;
#endif
GetBytes(dvifp, tfontptr->n, tfontptr->a + tfontptr->l);
tfontptr->n[tfontptr->a+tfontptr->l] = '\0';
tfontptr->font_mag = (long4)((
ActualFactor((long4)(1000.0*tfontptr->s/(double)tfontptr->d+0.5))
* ActualFactor(mag)
#ifdef USEPXL
* RESOLUTION * 5.0
#else
* RESOLUTION
#endif
) + 0.5);
/*
printf("[%ld]=%lf * %lf * %lf + 0.5 = %ld\n",
((long)(1000.0*tfontptr->s/(double)tfontptr->d+0.5)),
ActualFactor((long4)(1000.0*tfontptr->s/(double)tfontptr->d+0.5)),
ActualFactor(mag),
(double)RESOLUTION * 5,
(long)tfontptr->font_mag );
*/
#ifdef LJ_RESIDENT_FONTS
/* Pass in the name; fills in resident_p and resid (if resident). */
resident_font_located = (bool) TryResident(tfontptr);
if (tfontptr->resident_p)
return;
if (!(resident_font_located)) {
#endif
#ifdef KPATHSEA
{
kpse_glyph_file_type font_ret;
char *name;
unsigned dpi
= kpse_magstep_fix ((unsigned) (tfontptr->font_mag / 5.0 + .5),
RESOLUTION, NULL);
tfontptr->font_mag = dpi * 5; /* save correct dpi */
name = kpse_find_pk (tfontptr->n, dpi, &font_ret);
if (name)
{
font_found = _TRUE;
strcpy (tfontptr->name, name);
free (name);
if (!STREQ (tfontptr->n, font_ret.name)) {
fprintf (ERR_STREAM,
"dvilj: Font %s not found, using %s at %d instead.\n",
tfontptr->n, font_ret.name, font_ret.dpi);
tfontptr->c = 0; /* no checksum warning */
}
else if (!kpse_bitmap_tolerance ((double)font_ret.dpi, (double) dpi))
fprintf (ERR_STREAM,
"dvilj: Font %s at %d not found, using %d instead.\n",
tfontptr->name, dpi, font_ret.dpi);
if (!( (G_noverbatim) || (G_quiet) ) )
fprintf(ERR_STREAM,"%d: using font <%s>\n", plusid,tfontptr->name);
}
else
{
tfontptr->font_file_id = NO_FILE;
fprintf (ERR_STREAM,
"dvilj: Font %s at %u not found, characters will be left blank.\n",
tfontptr->n, dpi);
}
}
#else /* not KPATHSEA */
if (!(findfile(PXLpath,
tfontptr->n,
tfontptr->font_mag,
tfontptr->name,
_FALSE,
0))) {
Warning(tfontptr->name); /* contains error messsage */
tfontptr->font_file_id = NO_FILE;
#ifdef __riscos
MakeMetafontFile(PXLpath,tfontptr->n,tfontptr->font_mag);
#endif
}
else {
font_found = _TRUE;
if (!( (G_noverbatim) || (G_quiet) ) )
fprintf(ERR_STREAM,"%d: using font <%s>\n",
plusid,tfontptr->name);
}
#endif /* not KPATHSEA */
#ifdef LJ_RESIDENT_FONTS
}
#endif
tfontptr->plusid = plusid;
plusid++;
/* sprintf(tfontptr->psname,"%s.%ld.%d",
tfontptr->n,(long)tfontptr->font_mag,tfontptr->plusid);*/
#ifdef LJ
if (plusid >= HANDLE_MAX_FONTS)
Fatal("can handle only %d fonts! ask a wizzard...\n",
HANDLE_MAX_FONTS);
#endif
if (tfontptr != pfontptr) {
if (font_found) OpenFontFile();
else
pxlfp = NO_FILE;
}
#ifdef USEPXL
if ( pxlfp == NO_FILE ) { /* allow missing pxl files */
tfontptr->magnification = 0;
tfontptr->designsize = 0;
#endif
for (i = FIRSTFNTCHAR; i <= LASTFNTCHAR; i++) {
tcharptr = &(tfontptr->ch[i]);
#ifdef USEPXL
tcharptr->width = 0;
tcharptr->height = 0;
tcharptr->xOffset = 0;
tcharptr->yOffset = 0;
#endif
tcharptr->where.isloaded = _FALSE;
tcharptr->where.address.fileOffset = NONEXISTANT;
tcharptr->tfmw = 0;
}
#ifdef USEPXL
return;
}
t = (long4) NoSignExtend(pxlfp, 1);
if (t == 0) {
t = (long4) NoSignExtend(pxlfp, 1);
t = (long4) NoSignExtend(pxlfp, 2);
if (t == 1002)
tfontptr->id = id1002;
else if (t == 1001)
tfontptr->id = id1001;
else
Fatal("Unknown Version of PXL-format\n");
} else {
if (t == PK_PRE) {
unsigned char temp_byte;
temp_byte = (unsigned char) NoSignExtend(pxlfp, 1);
if (temp_byte != PK_ID) Fatal(
"Wrong Version of pk file! (%d should be 89)\n",
(int)temp_byte);
else
tfontptr->id = pk89;
} else
Fatal("unknown font format in file <%s> !\n",fontptr->name);
}
if ((tfontptr->id == id1002) || (tfontptr->id == id1001)) {
FSEEK(pxlfp, -20l,SEEK_END);
t = NoSignExtend(pxlfp, 4);
if ((tfontptr->c != 0) && (t != 0) && (tfontptr->c != t))
Warning("font = \"%s\",\n->tfm checksum = %lX,\n->pxl checksum = %lX",
tfontptr->name, tfontptr->c, t);
tfontptr->magnification = NoSignExtend(pxlfp, 4);
tfontptr->designsize = NoSignExtend(pxlfp, 4);
if (tfontptr->id == id1001)
FSEEK(pxlfp, (long) (NoSignExtend(pxlfp, 4) * 4),SEEK_SET);
else
FSEEK(pxlfp, (long) NoSignExtend(pxlfp, 4),SEEK_SET);
for (i = FIRSTFNTCHAR; i <= 127; i++) { /* only defined for 7bit*/
tcharptr = &(tfontptr->ch[i]);
tcharptr->width = (unsigned short) NoSignExtend(pxlfp, 2);
tcharptr->height = (unsigned short) NoSignExtend(pxlfp, 2);
tcharptr->xOffset = (short) SignExtend(pxlfp, 2);
tcharptr->yOffset = (short) SignExtend(pxlfp, 2);
tcharptr->where.isloaded = _FALSE;
if (tfontptr->id == id1001)
tcharptr->where.address.fileOffset = NoSignExtend(pxlfp,4) * 4;
else
tcharptr->where.address.fileOffset = NoSignExtend(pxlfp,4);
tcharptr->tfmw = (long4)
( (double)(NoSignExtend(pxlfp, 4))
* (double)tfontptr->s / (double) 0x100000 );
tcharptr->cw = (long4)(((double)tcharptr->tfmw/(double)hconv) + 0.5);
if (tcharptr->width > CHAR_WIDTH_LARGE ||
tcharptr->height > CHAR_HEIGTH_LARGE )
tcharptr->charsize = LARGE_SIZE;
else
tcharptr->charsize = SMALL_SIZE;
#ifdef LJ
max(tfontptr->max_width,tcharptr->width);
max(tfontptr->max_height,tcharptr->height);
if (tcharptr->yOffset > 0 && (int)tfontptr->max_yoff < (int)tcharptr->yOffset)
tfontptr->max_yoff = tcharptr->yOffset;
if ((depth = tcharptr->height - tcharptr->yOffset)>max_depth)
max_depth = depth;
#endif
}
#ifdef LJ
tfontptr->max_height = max_depth ? tfontptr->max_yoff+max_depth :
tfontptr->max_yoff+1;
#endif
} else { /* PK 89 format */
unsigned char temp_byte;
register unsigned char flag_byte;
long4 hppp, vppp, pkloc, packet_length;
int car, ii;
/* read comment */
for ( ii = temp_byte = (unsigned char) NoSignExtend(pxlfp, 1);
ii>0; ii--) {
flag_byte = (unsigned char) NoSignExtend(pxlfp, 1);
#ifdef DEBUG
if (Debug) fprintf(ERR_STREAM, "%c", flag_byte ) ;
#endif
}
#ifdef DEBUG
if (Debug) fprintf(ERR_STREAM, "\n");
#endif
pkloc = 3 + (int)temp_byte;
tfontptr->designsize = NoSignExtend(pxlfp, 4);
t = NoSignExtend(pxlfp, 4);
if ((tfontptr->c != 0) && (t != 0) && (tfontptr->c != t))
Warning("font = \"%s\",\n->tfm checksum = %lX,\n->pxl checksum = %lX",
tfontptr->name, tfontptr->c, t);
hppp = NoSignExtend(pxlfp, 4);
vppp = NoSignExtend(pxlfp, 4);
if (hppp != vppp)
Warning("aspect ratio is %ld:%ld (should be 1:1)!", (long)hppp,(long)vppp);
tfontptr->magnification = (long4)(hppp * 72.27 * 5 / 65536l + 0.5);
pkloc += 16;
flag_byte = skip_specials(&pkloc);
while (flag_byte != PK_POST) {
if ((flag_byte & 7) == 7) {
/* fprintf(ERR_STREAM,"\nRead long character preamble\n"); */
packet_length = (unsigned long4)NoSignExtend(pxlfp,4);
if ((car = (int)NoSignExtend(pxlfp, 4)) > (LASTFNTCHAR))
Fatal("Bad character (%d) in PK-File\n",(int)car) ;
tcharptr = &(tfontptr->ch[car]);
tcharptr->where.address.fileOffset = pkloc;
/* set pkloc to end_of_packet */
pkloc += packet_length + 8;
tcharptr->tfmw = (long4) NoSignExtend(pxlfp, 4);
(void) NoSignExtend(pxlfp, 4); /* horesc not used */
(void) NoSignExtend(pxlfp, 4); /* not used */
tcharptr ->width = (unsigned short) NoSignExtend(pxlfp, 4);
tcharptr ->height = (unsigned short) NoSignExtend(pxlfp, 4);
tcharptr ->xOffset = (short) SignExtend(pxlfp, 4);
tcharptr ->yOffset = (short) SignExtend(pxlfp, 4);
tcharptr ->where.isloaded = _FALSE;
} else if (flag_byte & 4) {
/* fprintf(ERR_STREAM,"Read extended short character preamble\n"); */
packet_length = ((long4) flag_byte & 3) * 65536l +
(unsigned short) NoSignExtend(pxlfp, 2);
if ((car = (int)NoSignExtend(pxlfp, 1)) > (LASTFNTCHAR))
Fatal("Bad character (%d) in PK-File\n",(int)car) ;
tcharptr = &(tfontptr->ch[car]);
tcharptr->where.address.fileOffset = pkloc;
/* set pkloc to end_of_packet */
pkloc += packet_length + 3;
tcharptr->tfmw = (long4) NoSignExtend(pxlfp, 3);
/*
{ register unsigned short t;
t = (unsigned short) NoSignExtend(pxlfp, 1);
tcharptr->tfmw = t * 65536l +
(unsigned short) NoSignExtend(pxlfp, 2);
}
*/
/* horesc not used */
(void) NoSignExtend(pxlfp, 2) ;
tcharptr ->width = (unsigned short) NoSignExtend(pxlfp,2);
tcharptr ->height = (unsigned short) NoSignExtend(pxlfp,2);
tcharptr ->xOffset = (short) SignExtend(pxlfp, 2);
tcharptr ->yOffset = (short) SignExtend(pxlfp, 2);
tcharptr ->where.isloaded = _FALSE;
} else {
/* fprintf(ERR_STREAM,"<Read short character preamble@>\n"); */
packet_length = ((long4)flag_byte & 3) * 256 +
NoSignExtend(pxlfp, 1) ;
if ((car = (int)NoSignExtend(pxlfp, 1)) > (LASTFNTCHAR))
Fatal("Bad character (%d) in PK-File\n",(int)car) ;
tcharptr = &(tfontptr->ch[car]);
tcharptr->where.address.fileOffset = pkloc;
/* set pkloc to end_of_packet */
pkloc += packet_length + 2 ;
tcharptr->tfmw = (long4) NoSignExtend(pxlfp, 3);
/*
{ register unsigned short t;
t = (unsigned short) NoSignExtend(pxlfp, 1);
tcharptr->tfmw = t * 65536l +
(unsigned short) NoSignExtend(pxlfp, 2);
}
*/
/* horesc not used */
(void) NoSignExtend(pxlfp, 1) ;
tcharptr ->width = (unsigned short) NoSignExtend(pxlfp,1);
tcharptr ->height = (unsigned short) NoSignExtend(pxlfp,1);
tcharptr ->xOffset = (short) SignExtend(pxlfp, 1);
tcharptr ->yOffset = (short) SignExtend(pxlfp, 1);
tcharptr ->where.isloaded = _FALSE;
}
tcharptr->tfmw = (long4)
( tcharptr->tfmw * (double)tfontptr->s / (double) 0x100000 );
tcharptr->cw = (long4)(((double)tcharptr->tfmw /
(double)hconv) + 0.5);
if (tcharptr->width > CHAR_WIDTH_LARGE ||
tcharptr->height > CHAR_HEIGTH_LARGE )
tcharptr->charsize = LARGE_SIZE;
else
tcharptr->charsize = SMALL_SIZE;
#ifdef LJ
/*
printf("char=%d: this=%d, max_width=%d, this=%d,max_height=%d, this=%d,max_yoff=%d\n",
car, tcharptr->width, tfontptr->max_width,
tcharptr->height,tfontptr->max_height,
tcharptr->yOffset,tfontptr->max_yoff);
*/
max(tfontptr->max_width, tcharptr->width);
max(tfontptr->max_height,tcharptr->height);
if (tcharptr->yOffset > 0 && (int)tfontptr->max_yoff < (int)tcharptr->yOffset)
tfontptr->max_yoff = tcharptr->yOffset;
if ((depth = tcharptr->height - tcharptr->yOffset) > max_depth)
max_depth = depth;
#endif
/*
fprintf(ERR_STREAM,"char=%d, yotcharptr=%lx, flag_byte=%d, font=%lx\n",car, tcharptr,flag_byte,tfontptr);
*/
tcharptr->flag_byte = flag_byte;
FSEEK(pxlfp, (long) pkloc,SEEK_SET);
flag_byte = skip_specials(&pkloc);
} /* end of while */
#ifdef LJ
tfontptr->max_height = max_depth ? tfontptr->max_yoff+max_depth :
tfontptr->max_yoff+1;
#endif
/*
printf("fontid=%d: max_width=%u, max_height=%d, max_yoff=%u\n",
tfontptr->plusid, tfontptr->max_width,
tfontptr->max_height, tfontptr->max_yoff);
*/
#else
if ( pxlfp == NO_FILE ) /* allow missing pxl files */
return;
gfin = pxlfp;
seekpost();
readpost();
if ((tfontptr->c != 0) && (checksum != 0) && (tfontptr->c != checksum))
Warning("font = \"%s\",\n-->font checksum = %d,\n-->dvi checksum = %d",
tfontptr->name, tfontptr->c, checksum);
for(i=FIRSTFNTCHAR; i<=LASTFNTCHAR; i++) {
if (char_exists[i]) {
tcharptr = &(tfontptr->ch[i]);
tcharptr->tfmw = (long4)(((float)tfm_wd[i]*(float)tfontptr->s) /
(float)((long4)1l<<20));
tcharptr->where.address.fileOffset = char_pointer[i];
}
#ifdef LJ
/* GF USER PLEASE CHECK IF THIS CODE WORKS
tfontptr->max_width = gf_font_max_m;
tfontptr->max_height = gf_font_max_n;
tfontptr->max_yoff = gf_font_min_n;
*/
#endif
#endif
/*****************************************************************************/
/*if (tcharptr->charsize==LARGE_SIZE)
fprintf(ERR_STREAM,"%d:\t <%c> w=%d h=%d xO=%d yO=%d tfmw=%ld cw=%ld %d\n",
i,(char) i,
tcharptr->width,tcharptr->height,tcharptr->xOffset,tcharptr->yOffset,
(long)tcharptr->tfmw, (long)tcharptr->cw, (int)(tcharptr->charsize));
*/
/*****************************************************************************/
}
}
/*-->SetFntNum*/
/**********************************************************************/
/**************************** SetFntNum *****************************/
/**********************************************************************/
void
SetFntNum(long4 k, bool Emitting)
/* this routine is used to specify the font to be used in printing future
characters */
{
#ifdef LJ
static unsigned short plusid = 0;
#endif
fontptr = hfontptr;
while ((fontptr != NULL) && (fontptr->k != k))
fontptr = fontptr->next;
if (fontptr == NULL)
Fatal("font %ld undefined", (long)k);
if (Emitting && fontptr->font_file_id != NO_FILE) {
if (!fontptr->used_on_this_page
#ifdef LJ_RESIDENT_FONTS
&& !fontptr->resident_p
#endif
) {
fontptr->used_on_this_page = _TRUE;
#ifdef LJ
if (++fonts_used_on_this_page > MAX_FONTS_PER_PAGE) {
qfprintf(ERR_STREAM,"this is the %d. font on this page!",
fonts_used_on_this_page);
qfprintf(ERR_STREAM," (max = %d) rastering characters!\n",
MAX_FONTS_PER_PAGE);
rasterfont[fontptr->plusid] = _TRUE;
}
#endif
}
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "Switching to font #%ld (%s).\n", k, fontptr->n);
#endif
/* activate font */
#ifdef IBM3812
sprintf(PMPformat, "\323%c", (unsigned char)fontptr->plusid);
PMPout(2, PMPformat);
#endif
#ifdef LJ
if (!rasterfont[fontptr->plusid]) {
#ifdef LJ_RESIDENT_FONTS
if (fontptr->resident_p) {
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "Resident font #%d.\n", fontptr->resid);
#endif
EMIT(EMTO, "\033(%s", fontptr->symbol_set); EMFLUSH;
EMIT(EMTO, "\033(s%up%.2f%c%us%db%uT",
fontptr->spacing,
/* height in points, or pitch */
fontptr->spacing ? fontptr->s / 65536.0
: fontptr->pitch ,
fontptr->spacing ? 'v' : 'h', /* height or pitch? */
fontptr->style, /* upright, italic, ... */
fontptr->weight, /* regular, bold, ... */
fontptr->resid); EMFLUSH;
} else
#endif /* LJ_RESIDENT_FONTS */
if (fontptr->plusid>0) {EMIT(EMTO, "\033(%dX", fontptr->plusid); EMFLUSH;}
else {EMIT(EMTO, "\033(X"); EMFLUSH;}
}
/* else fprintf(ERR_STREAM,"I am doing rasterfont for plusid=%d instead\n",
fontptr->plusid);
*/
#endif
}
#ifdef LJ /* reassignment of printer font id 0.48 */
else if (fontptr->font_file_id != NO_FILE
#ifdef LJ_RESIDENT_FONTS
&& !fontptr->resident_p
#endif
) {
if (fontptr->ncdl == 0) {
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "Changing plusid from %d to %d\n",
fontptr->plusid, (int)plusid);
#endif
fontptr -> plusid = plusid;
plusid ++;
}
}
#endif
}
/*-->SkipFontDef*/
/**********************************************************************/
/**************************** SkipFontDef ***************************/
/**********************************************************************/
void
SkipFontDef(void)
{
int a, l;
char n[STRSIZE];
(void) NoSignExtend(dvifp, 4);
(void) NoSignExtend(dvifp, 4);
(void) NoSignExtend(dvifp, 4);
a = (int) NoSignExtend(dvifp, 1);
l = (int) NoSignExtend(dvifp, 1);
GetBytes(dvifp, n, a + l);
}